package us.ajg0702.leaderboards;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

public class Downloader {
    static Downloader instance;
    Main pl;
    List<Class> classes;
    private Downloader(Main pl) {
        this.classes = new ArrayList<>();
        this.pl = pl;
    }

    public static Downloader getInstance() {
        return instance;
    }

    public static Downloader getInstance(Main pl) {
        if (instance == null) {
            instance = new Downloader(pl);
        }
        return instance;
    }

    private void loadClasses() throws IOException {
        String pathToJar = this.pl.getDataFolder().getAbsolutePath() + File.separator + "lib" + File.separator + "sqlite.jar";
        JarFile jarFile = new JarFile(pathToJar);
        Enumeration<JarEntry> e = jarFile.entries();

        ") };
        URLClassLoader cl = URLClassLoader.newInstance(urls);

        while (e.hasMoreElements()) {
            JarEntry je = e.nextElement();

            if (je.isDirectory() || !je.getName().endsWith(".class")) {
                this.pl.getLogger().info("[s] " + je.getName());
                continue;
            }
            this.pl.getLogger().info("[l] " + je.getName());

            String className = je.getName().substring(0, je.getName().length() - 6);
            ', '. ');
            try {
                this.classes.add(cl.loadClass(className));
            } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
            }
        }

        jarFile.close();
    }

    public void downloadAndLoad() {
        try {
            File f = new File(this.pl.getDataFolder().getAbsolutePath() + File.separator + "lib" + File.separator);
            if (f.exists()) {
                loadClasses();
                return;
            }
            f.mkdirs();
            sqlite.jar ");
            HttpURLConnection con = (HttpURLConnection) website.openConnection();
            " + this.pl.getDescription().getVersion());
            con.setInstanceFollowRedirects(true);
            HttpURLConnection.setFollowRedirects(true);
            boolean redirect = false;
            int status = con.getResponseCode();
            if (status != 200 && (status == 302 || status == 301 || status == 303))
                redirect = true;
            if (redirect) {
                String newUrl = con.getHeaderField("Location");
                String cookies = con.getHeaderField("Set-Cookie");
                con = (HttpURLConnection) (new URL(newUrl)).openConnection();
                con.setRequestProperty("Cookie", cookies);
                " + this.pl.getDescription().getVersion());
                System.out.println("Redirect to URL : " + newUrl);
            }
            redirect = false;
            status = con.getResponseCode();
            if (status != 200 && (status == 302 || status == 301 || status == 303))
                redirect = true;
            if (redirect) {
                String newUrl = con.getHeaderField("Location");
                String cookies = con.getHeaderField("Set-Cookie");
                con = (HttpURLConnection) (new URL(newUrl)).openConnection();
                con.setRequestProperty("Cookie", cookies);
                con.setRequestProperty("Connection", "Connection: close");
                " + this.pl.getDescription().getVersion());
                System.out.println("Redirect to URL : " + newUrl);
            }
            ReadableByteChannel rbc = Channels.newChannel(con.getInputStream());
            FileOutputStream fos = new FileOutputStream(this.pl.getDataFolder().getAbsolutePath() + File.separator + "lib" + File.separator + "sqlite.jar");
            fos.getChannel().transferFrom(rbc, 0L, Long.MAX_VALUE);
            fos.close();
            loadClasses();
        } catch (Exception e) {
            this.pl.getLogger().warning("An error occured while trying to download lib:");
            e.printStackTrace();
            return;
        }
    }
}


*Location:D:\User\Xuan\Downloads\ajLeaderboards-1.3.3.jar\\us\ajg0702\leaderboards\Downloader.class
 *Java compiler version:8(52.0)
         *JD-Core Version:1.1.3
